package com.wanwu.channel.dao.inter;

import com.wanwu.channel.dao.condition.BaseCondition;
import com.wanwu.channel.dao.entity.ChannelPayEntity;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ChannelPayDao {

    int insert(ChannelPayEntity record);

    int insertSelective(ChannelPayEntity record);

    ChannelPayEntity selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(ChannelPayEntity record);

    int updateByPrimaryKey(ChannelPayEntity record);

    /**
     * 根据out_trade_no和pay_type 查询
     * @param outTradeNo
     * @param payType
     * @return
     */
    ChannelPayEntity selectByOutTradeNoAndPayType(String outTradeNo, int payType);

    int updateNotify(String tradeStatus, String notifyData, String notifyType, Date notifyTime, Date updateTime,
                     String notifyId, int payStatus, String tradeNo, String outTradeNo, int payType);

    int updateErrorNotify(String tradeStatus, String notifyData, String notifyType, Date notifyTime, Date updateTime,
                          String notifyId, String errorCode, String errorMsg, int payStatus, String tradeNo, String outTradeNo, int payType);

    ChannelPayEntity selectByTradeNoOrOutTradeNo(int payType, String tradeNo, String outTradeNo);

    int updateQuery(String tradeStatus, int payStatus, Date payTime, Date updateTime, int payType, String outTradeNo);

    /**
     * 通过业务线订单号查询订单信息
     * @param outTradeNo
     * @return
     */
    ChannelPayEntity queryByBizOrderNo(@Param("bizOrderNo") String outTradeNo,@Param("bizCode") String bizCode);

    ChannelPayEntity queryByBizOrderNoFMaster(@Param("bizOrderNo") String bizOrderNo,@Param("bizCode") String bizCode);

    /**
     * 根据渠道单号更新预下单结果到数据库
     * @param channelPayEntity
     * @return
     */
    //添加bizcode
    int updateByChannelNo(ChannelPayEntity channelPayEntity);

    /**
     * 根据业务线单号和业务线码查询海关总署所需相关信息
     * */
    Map getCostomQryInfoByBizOrderNo(@Param("bizOrderNo") String bizOrderNo,@Param("subOrderNo") String subOrderNo, @Param("bizCode") String bizCode);

    // 以下是后台的方法
    Integer countNum(@Param("entity") ChannelPayEntity entity, @Param("cond") BaseCondition condition);

    List<ChannelPayEntity> qryList(@Param("entity") ChannelPayEntity entity, @Param("cond") BaseCondition condition);

    //临时刷数 sql
    List<ChannelPayEntity> qryMerchantNoEmptyList(@Param("id") Long id);

    ChannelPayEntity queryByChannelNoFMaster(@Param("channelNo")String channelNo);
}